package com.qf.day1126;


import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.config.IniSecurityManagerFactory;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.Factory;

/**
 * IntelliJ IDEA -> shiro1125
 * 2019/11/25 21:00
 *
 * @author zmyao
 * 别看，我是渣渣。
 */
public class Md5TestRealm
{
    public static void main(String[] args) {
//        Factory<SecurityManager> iniSecurityManagerFactory = new IniSecurityManagerFactory("classpath:users.ini");
        Factory<SecurityManager> iniSecurityManagerFactory = new IniSecurityManagerFactory("classpath:myrealmb.ini");
        SecurityManager instance = iniSecurityManagerFactory.getInstance();
        SecurityUtils.setSecurityManager(instance);
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken("admin1", "123");
        subject.login(token);
        boolean result = subject.isAuthenticated();
        System.out.println("认证状态1："+result);
        subject.logout();
        boolean result2 = subject.isAuthenticated();
        System.out.println("认证状态2："+result2);
    }
}
